package com.tongguan.paypos.view;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.tongguan.paypos.R;

public class SpinerPopWindow extends PopupWindow{
	
	private Context mContext;
	private ListView mListView;
	private PopAdapter mAdapter;
	private OnItemClickListener listener;
	public SpinerPopWindow(Context context, OnItemClickListener listener) {
		super(context);
		this.mContext = context;
		this.listener = listener;
		init();
	}

	private void init() {
		View view = LayoutInflater.from(mContext).inflate(R.layout.spinner_window_layout, null);
		setContentView(view);
		setWidth(LayoutParams.WRAP_CONTENT);
		setHeight(LayoutParams.WRAP_CONTENT);
		setFocusable(true);
		ColorDrawable dw = new ColorDrawable(0x00);
		setBackgroundDrawable(dw);
		mListView = (ListView) view.findViewById(R.id.lv_spinner);
		mAdapter = new PopAdapter(mContext); 
		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(listener);

	}


	public void setData(ArrayList<String> dateList) {
		mAdapter.setData(dateList);
	}
}
